/**
 * Alipay.com Inc.
 * Copyright (c) 2004-2018 All Rights Reserved.
 */
package com.antcloud.demo.antscheduler.handlers;

import java.util.Date;
import java.util.concurrent.ThreadPoolExecutor;

import com.alipay.antschedulerclient.common.ClientCommonResult;
import com.alipay.antschedulerclient.handler.ISimpleJobHandler;
import com.alipay.antschedulerclient.model.JobExecuteContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author qian.lqlq
 * @version $Id: StepTowHandler.java, v 0.1 2018年08月24日 11:18 qian.lqlq Exp $
 */
public class StepTowHandler implements ISimpleJobHandler {

    private final Logger LOGGER = LoggerFactory.getLogger(getClass());


    @Override
    public ClientCommonResult handle(JobExecuteContext jobExecuteContext) {

        LOGGER.info(String.format("StepTowHandler start %s", new Date()));
        if (!"stepOne".equals(jobExecuteContext.getCustomParam("myParam"))) {
            return ClientCommonResult.buildFailResult("custom param was not found");
        }
        try {
            Thread.sleep(30 * 1000);
        } catch (Exception e) {

        }
        if (SuccessUtil.isSucess(50)) {
            return ClientCommonResult.buildSuccessResult();
        }
        LOGGER.info(String.format("StepTowHandler end %s", new Date()));
        return ClientCommonResult.buildFailResult("handle failed");
    }

    @Override
    public ThreadPoolExecutor getThreadPool() {
        return null;
    }

    @Override
    public String getName() {
        return "stepTwo";
    }
}